//
//  JYJVCOfSetPassword.m
//  HappyListen
//
//  Created by 冀永金 on 16/8/27.
//  Copyright © 2016年 冀永金. All rights reserved.
//

#import "JYJVCOfSetPassword.h"
#import "Masonry.h"
#import "BaseButton.h"
#import "JYJNetWorkParser.h"
#import "JYJTAMacro.h"
#import "JYJVCOfSet.h"
#import "JYJMusicMiniView.h"
@interface JYJVCOfSetPassword ()
@property (nonatomic, retain) UITextField *textFieldOfPhone ;
@property (nonatomic, retain) UITextField *textOfSecurityCode;
@end

@implementation JYJVCOfSetPassword

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"设置登录密码";
    self.view.backgroundColor = [UIColor colorWithRed:0.09 green:0.09 blue:0.11 alpha:1.00];
    [self configSubViews];
     self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
    // Do any additional setup after loading the view.
}
- (void)configSubViews {
    self.textFieldOfPhone = [[UITextField alloc]init];
    _textFieldOfPhone.placeholder = @"请输入6-16位密码";
    _textFieldOfPhone.backgroundColor = [UIColor colorWithRed:0.07 green:0.07 blue:0.08 alpha:1.00];
    _textFieldOfPhone.secureTextEntry = YES;
    [self.view addSubview:_textFieldOfPhone];
    _textFieldOfPhone.textColor = [UIColor whiteColor];
    // 设置placeholder的字体颜色
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    dic[NSForegroundColorAttributeName] = [UIColor whiteColor];
    NSAttributedString *attribute = [[NSAttributedString alloc] initWithString:_textFieldOfPhone.placeholder attributes:dic];
    [_textFieldOfPhone setAttributedPlaceholder:attribute];
    [_textFieldOfPhone mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view.mas_top).with.offset(20);
        make.left.equalTo(self.view.mas_left).with.offset(5);
        make.right.equalTo(self.view.mas_right).with.offset(-5);
        make.height.mas_equalTo(50);
    }];
    
    self.textOfSecurityCode = [[UITextField alloc]init];
    _textOfSecurityCode.placeholder = @"请确认输入的密码";
    _textOfSecurityCode.backgroundColor = [UIColor colorWithRed:0.07 green:0.07 blue:0.08 alpha:1.00];
    _textOfSecurityCode.secureTextEntry = YES;
    _textOfSecurityCode.textColor = [UIColor whiteColor];
    // 设置placeholder的字体颜色
    NSMutableDictionary *dict = [NSMutableDictionary dictionary];
    dict[NSForegroundColorAttributeName] = [UIColor whiteColor];
    NSAttributedString *attributeSe = [[NSAttributedString alloc] initWithString:_textOfSecurityCode.placeholder attributes:dict];
    [_textOfSecurityCode setAttributedPlaceholder:attributeSe];
    [self.view addSubview:_textOfSecurityCode];
    [_textOfSecurityCode mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_textFieldOfPhone.mas_bottom).with.offset(2);
        make.left.equalTo(self.view.mas_left).with.offset(5);
        make.right.equalTo(self.view.mas_right).with.offset(-5);
        make.height.mas_equalTo(50);
    }];
    
    BaseButton *buttonOfFinish = [BaseButton buttonWithType:UIButtonTypeSystem];
    [buttonOfFinish setTitle:@"完成" forState:UIControlStateNormal];
    buttonOfFinish.backgroundColor = [UIColor redColor];
    [buttonOfFinish setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self.view addSubview:buttonOfFinish];
    [buttonOfFinish mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_textOfSecurityCode.mas_bottom).with.offset(300);
        make.left.equalTo(self.view.mas_left).with.offset(20);
        make.right.equalTo(self.view.mas_right).with.offset(-20);
        make.height.mas_equalTo(50);
    }];
    buttonOfFinish.layer.cornerRadius = 20;
    buttonOfFinish.clipsToBounds = YES;
    [buttonOfFinish addTarget:self action:@selector(handleFinish:) forControlEvents:UIControlEventTouchUpInside];
    
}
- (void)handleFinish:(BaseButton *)button {
    
    NSString *str1 = @"json=%7B%22username%22%3A%22";
    NSString *str3 = @"%22%2C%22password%22%3A%22";
    NSString *str4 = [NSString stringWithFormat:@"%@",self.textOfSecurityCode.text];
    NSString *str5 = BRACKETS_STR;
    str4 = [[[[str1 stringByAppendingString:self.userName] stringByAppendingString:str3]stringByAppendingString:str4]stringByAppendingString:str5];
    [JYJNetWorkParser POST:@"http://www.aiyinsitanfm.com/mobile/user/signup.jhtml" andBody:str4 andBodyStyle:JYJBodyString andHeader:HEADDIC andResponse:JYJJSON andSuccessBlock:^(id result) {
        NSLog(@"%@",result);
    
        NSDictionary *status = [result objectForKey:@"status"];
        NSNumber *succed =[status objectForKey:@"succeed"];
        if ([succed isEqualToNumber:@1]) {
            JYJVCOfSet *set = [[JYJVCOfSet alloc]init];
            [self.navigationController pushViewController:set animated:YES];
            set.infoDicTwo = result;
        }
        
        
    } andFailureBlock:^(NSError *error) {
        
    }];
    
    
    
    

}
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [JYJMusicMiniView  shareMiniView].hidden = YES;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
